Ext.define('PHT.CheckURLsCfgRightGrid', {
    extend: 'Ext.grid.Panel',
    alias: ['widget.chkurlcheckinglgrid'], 
    
    id: 'checking-grid',
    title: 'Checking URL',
    hideHeaders: true,
    flex: 2,
    region: 'east',
    
    onApplyClick: function(){
    	var store_available = Ext.data.StoreManager.lookup('available-store');
    	store_available.sync();
    	var store_checking = Ext.data.StoreManager.lookup('checkingURL-store');
    	store_checking.sync();
    },
    
    initComponent: function() {
        var me = this;
        
        Ext.applyIf(me, {
        	dockedItems: [{
                xtype: 'toolbar',
                dock: 'bottom',
                items: [{
                    //iconCls: 'icon-delete',
                    text: 'Apply',
                    //disabled: true,
                    itemId: 'apply',
                    scope: this,
                    handler: this.onApplyClick
                }]
            }],
            columns: [
                {
                    xtype: 'gridcolumn',
                    dataIndex: 'name',
                    flex: 1
                }
            ],
            store:Ext.create('Ext.data.Store', {
            	storeId: 'checkingURL-store',
                model: 'PHT.MODEL.Item',   
                proxy: {
                    type: 'ajax',
                    //url : 'initAvailableURLs.do?n='+ new Date(),
                    api:{
                    	read: 'urlread.do?isavailable=1&n='+ new Date(),
                        create: 'urlcreate.do?isavailable=1&n='+ new Date(),
                        update: 'urlupdate.do?isavailable=1&n=' + new Date(),
                        destroy: 'urldestroy.do?isavailable=1&n=' + new Date()
                    },
                    reader: {
                        type: 'json',
                        root: 'names'
                    },
                    writer:{
                    	type: 'json',
                        writeAllFields: true,
                        root: 'names'
                    }
                },
                autoLoad: true,
                //autoSync: true
            }),
        	frame: true,
        });        
        me.callParent(arguments);
    }
});